const app = getApp()
const http = (url, data = {}, method = "get") => {
  let path = app.globalData.baseUrl + url
  let token = wx.getStorageSync('token')
  return new Promise((resolve, reject) => {
    wx.request({
      url: path,
      data: data,
      method: method,
      header: {
        'content-type': 'application/json',
        'Authorization': token
      },
      success(res) {
        resolve(res.data)
      },
      fail(res) {
        reject(res.data);
      }
    })
  })
}
const get = (url, data) => http(url, data, "get")
const post = (url, data) => http(url, data, "post")
module.exports = {
  get,
  post
}